package xujun.control.toolbar;

import xujun.control.XContorlUtil;

import javax.swing.*;
import java.awt.*;


/**
 * @author 徐骏
 * @data 2010-7-6
 */
public class XToolBarRoverButton extends XToolBarButton {
    private Color roverDyeColor;

    public XToolBarRoverButton() {
        roverDyeColor = new Color(86, 146, 61);
    }

    public void setIcon(Icon icon) {
        super.setIcon(icon);
        if (icon == null) {
            setPressedIcon(null);
            setRolloverIcon(null);
        } else {
            java.awt.Image image = XContorlUtil.iconToImage(icon);
            Icon roverIcon = XContorlUtil.createDyedIcon(new ImageIcon(image), roverDyeColor);
            Icon pressedIcon = XContorlUtil.createMovedIcon(roverIcon);
            setRolloverIcon(roverIcon);
            setPressedIcon(pressedIcon);
        }
    }
}
